﻿using Brjnk.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MapsTest
{
    [TestClass()]
    public class DistanceTest
    {
        private TestContext testContextInstance;

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes

        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //

        #endregion Additional test attributes

        [TestMethod()]
        public void GetDistanceTest()
        {
            GpsCoordinates Coordinate1 = new GpsCoordinates(48, 16);
            GpsCoordinates Coordinate2 = new GpsCoordinates(49, 15);
            var distance = Coordinate1 - Coordinate2;
            Assert.AreEqual(distance.GetDistanceValue(DistanceUnit.Metre), 133300.0, 1000);
            Assert.AreEqual(distance.GetDistanceValue(DistanceUnit.Kilometre), 133.300, 1);
            Assert.AreEqual(distance.GetDistanceValue(DistanceUnit.Mile), 82.82, 2);
            Assert.AreEqual(distance.ToString(DistanceUnit.Kilometre, 0), "134 km");
        }
    }
}